<?php
require('config.php');

        $name=$_REQUEST['huan_name'];
        if($name=='jingpin') $sql="select goodsId,goodsImg,goodsName,shopPrice,shopId from ".$oto."_goods where `isBest`=1 and goodsStatus='1' and `isSale`=1 and goodsFlag='1' and goodsStock>0 order by rand() limit 3";
        else if($name=='xinpin') $sql="select goodsId,goodsImg,goodsName,shopPrice,shopId from ".$oto."_goods where `isNew`=1 and goodsStatus='1' and `isSale`=1 and goodsFlag='1' and goodsStock>0 order by rand() limit 3";
        else if($name=='rexiao') $sql="select goodsId,goodsImg,goodsName,shopPrice,shopId from ".$oto."_goods where `isHot`=1 and goodsStatus='1' and `isSale`=1 and goodsFlag='1' and goodsStock>0 order by rand() limit 3";
        else if($name=='tejia')
        {
            $sql="select catId from ".$oto."_goods_cats where isShow='1' and isFixed='1' ";
            $result=$db->query($sql);
            while($row=$result->fetch_assoc()){
                $goods_cats[]=$row;//将取得的所有数据赋值给person_info数组
            }
            $catId=$goods_cats[0]['catId'];
            $sql="select goodsId,goodsImg,goodsName,shopPrice,shopId from ".$oto."_goods where goodsCatId1='{$catId}' and goodsStatus='1' and goodsFlag='1' and `isSale`=1 and goodsStock>0 order by rand() limit 3";     
        } 
        else if($name=='jingxuan')
        {
            $sql="select catId from ".$oto."_goods_cats where isShow='1' and isFixed='2' ";
            $result=$db->query($sql);
            while($row=$result->fetch_assoc()){
                $goods_cats[]=$row;//将取得的所有数据赋值给person_info数组
            }
            $catId=$goods_cats[0]['catId'];
            $sql="select goodsId,goodsImg,goodsName,shopPrice,shopId from ".$oto."_goods where goodsCatId1='{$catId}' and goodsFlag='1' and `isSale`=1 and goodsStatus='1' and goodsStock>0 order by rand() limit 3";    
        } 
        else $sql="select goodsId,goodsImg,goodsName,shopPrice,shopId from ".$oto."_goods where `isSale`=1 and goodsFlag='1' and goodsStatus='1' and `isSale`=1 and goodsStock>0 order by rand() limit 3";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$person_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		echo json_encode($person_info);
?>